// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
import { Sequelize, DataTypes, Model } from 'sequelize';
import { Application } from '../declarations';
import { HookReturn } from 'sequelize/types/hooks';

export default function (app: Application): typeof Model {
  const sequelizeClient: Sequelize = app.get('sequelizeClient');
  const buy = sequelizeClient.define('buy', {
    
    // 购物人
    shopName:{
		 type:DataTypes.STRING,
      allowNull: false,
      unique: true
    },
    // 购物车列表
    shoppingCartList:{
		 type:DataTypes.JSON,
      allowNull: false,

    },
    // 邮寄地址  
    address:{
		 type:DataTypes.STRING,
	 	},
    // 收货人 
    consignee:{
		 type:DataTypes.STRING,
		 },
    // 电话号码 
    telephone:{
		 type:DataTypes.STRING,
		 },
  }, {
    hooks: {
      beforeCount(options: any): HookReturn {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  (buy as any).associate = function (models: any): void {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return buy;
}
